const fileUtil = require('./fileUtil')
var fs = require('fs')
const glob = require('glob')

const moduleName = 'mlp'
const folderName = 'mlp'

// 拷贝所有的html
glob.sync('./dist/*.*').forEach((file, name) => {
  const path = file.split('/')[2]// 获取html所在目录
  const targetDirectory = '../' + moduleName + '/src/main/resources/templates/' + folderName + '/' + path
  fileUtil.deleteFolder(targetDirectory)
  fs.copyFileSync(file, targetDirectory)
})
// 先删除目录
const webappDirectory = '../' + moduleName + '/src/main/resources/webapp/'
fileUtil.deleteFolder(webappDirectory)
// 拷贝静态资源
fileUtil.copyFolder('./dist/webapp', webappDirectory)
// 拷贝上下文
fs.copyFileSync(`./src/utils/context.js`, webappDirectory + 'context.js')
